# Contributor: Anjandev Momi <anjan@momi.ca>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=cura
# uranium and curaengine packages must be updated in sync with this verion number
# py3-pynest2d and fdm-materials should be checked as well, but their versions are not always in sync
pkgver=5.2.2
pkgrel=1
pkgdesc="3D printer / slicing GUI built on top of the Uranium framework"
url="https://ultimaker.com/software/ultimaker-cura"
arch="noarch !ppc64le !x86 !armhf !riscv64 !s390x !armv7" # ppc64le: no py3-keyring
# x86: no curaengine
# armhf: no uranium, qt5-qtquickcontrols, qt5-qtquickcontrols2, qt5-qtgraphicaleffects
# riscv64: no uranium
# s390x: no py3-trimesh, no py3-numpy-stl
# armv7: no py3-trimesh
license="LGPL-3.0-or-later"
# add cura-binary-data to depends when packaged
depends="
	curaengine
	fdm-materials
	uranium
	py3-arcus
	py3-keyring
	py3-numpy-stl
	py3-pyclipper
	py3-pynest2d
	py3-pyserial
	py3-qt6
	py3-requests
	py3-trimesh
	py3-zeroconf
	"
makedepends="samurai cmake gettext gettext-dev" # needs msginit from gettext
checkdepends="py3-pytest"
subpackages="$pkgname-lang"
source="$pkgname-$pkgver.tar.gz::https://github.com/Ultimaker/Cura/archive/refs/tags/$pkgver.tar.gz
	AppDesktopData.patch
	CuraVersion.patch
	cmake-helpers.patch
	cmake.patch"
builddir="$srcdir/Cura-$pkgver"
options="!check" # tests broken after v5.x

build() {
	local pyver="$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
	cmake -B build -G Ninja \
		-DCURA_VERSION=$pkgver \
		-DPython_VERSION=$pyver \
		-DURANIUM_DIR=/usr/share/uranium \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DGETTEXT_MSGINIT_EXECUTABLE=msginit \
		-DCURA_BINARY_DATA_DIRECTORY=/usr/share/cura \
		-DCMAKE_BUILD_TYPE=minsizerel
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	mv $pkgdir/usr/bin/cura_app.py $pkgdir/usr/bin/cura

	# don't ever send any user or print info through the internet to Ultimaker
	rm -rf "$pkgdir/usr/lib/cura/plugins/SliceInfoPlugin"

	install -d "$pkgdir"/usr/share/locale
	mv "$pkgdir"/usr/share/cura/resources/i18n/* "$pkgdir"/usr/share/locale/
}

sha512sums="
5d4e0fdc740d0c048905e2b87cc8c73eedea59b54766b74760505902007b365582d22b46b1cfdcd6914828840865c10a3beb0ef6a1f04ea181c81d44f42434bc  cura-5.2.2.tar.gz
214e373f6cab7e3ccac12c96d1b5ca636d8d1e9ecdadaae84fc28fb429969c7c2d6055ce2a01b6db3ad85ab6cbc8d135cf2c26c77d7cfe13a73eb81aa5e85f11  AppDesktopData.patch
e3bb302db70ca195b2ce9831e71302c8ee2a51955fecc7264a495d7d4fc9c107cfd48811aa5865f16671e7b1ae126f95d3d7bbb6a70f367f7f91a2b32bce377b  CuraVersion.patch
0db4ff97e7f82ae1a9dbc9c330d08c3e46249feeb3fb630f7c4e2de73749327337ec041680c39a07e0b5034c1b3f3656d75614ab4dc2f39861c8e27bdb2a58ef  cmake-helpers.patch
05a73f892700ff6279230385b04180873a62b7413fa7f7d55ae150f1bcee57ef05eda0bd7fe444fe660ab66a044c958f42badd33b743fca81033ae8f19dd3805  cmake.patch
"
